import request from "@/utils/index.js";

// 获取职员列表
export const getEmployeePageService = (currentPage, pageSize, empName, account) => {
    return request.get("/api/employee/page", {params: {currentPage, pageSize, empName, account}});
};


// 添加职员
export const addEmployeeService = (data) => {
    return request.post("/api/employee", data);
};

// 删除职员的服务方法
export const deleteEmployeeService = (ids) => {
    // 将多个 ID 用逗号连接起来
    //如果 ids 是一个数组，则将数组中的元素用逗号连接起来
    if (Array.isArray(ids)) {
        ids = ids.join(",");
    }

    // 如果 ids 是一个数字，则将其转换为字符串
    if (typeof ids === "number") {
        ids = ids.toString();
    }
    // const idsParam = ids.join(",");
    return request.delete(`/api/employee?ids=${ids}`);
};

// 修改职员
export const updateEmployeeService = (data) => {
    console.log(data);
    return request.put("/api/employee", data);
};

// 获取全部销售人员
export const getEmployeeListService = () => {
    return request.get("/api/employee/list");
};

